<?php

namespace app\common\job;

use think\queue\Job;

/**
 * 巨量回传
 * Class Oceanengine
 * @package app\common\job
 */
class Oceanengine
{
    /**
     * fire是消息队列默认调用的方法
     * @param Job $job 当前的任务对象
     * @param array|mixed $data 发布任务时自定义的数据
     */
    public function fire(Job $job, $data)
    {
        $event_type = $data['event_type'] ?? '';
        $clickid = $data['clickid'] ?? '';

        try {

            $this->getOceanengine()->conversion($event_type, $clickid);
        } finally {

            $job->delete();
        }

    }

    private function getOceanengine(): \oceanengine\Oceanengine
    {
        return app(\oceanengine\Oceanengine::class);
    }
}
